import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../widgets/text_button.dart';
import 'upload_music_controller.dart';

class UploadMusicPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetX<UploadMusicController>(
        init: UploadMusicController(),
        builder: (controller) {
          return Scaffold(
              appBar: AppBar(title: Text('上传音乐')),
              body: Container(
                margin: EdgeInsets.all(15),
                child: Row(
                  children: [
                    controller.filePath.isEmpty
                        ? MyTextButton(
                            text: "添加文件",
                            height: 25,
                            backgroundColor: Colors.transparent,
                            sideColor: Colors.transparent,
                            textStyle: TextStyle(color: Colors.teal),
                            margin: EdgeInsets.only(left: 15),
                            confirm: () {
                              controller.chooseFile();
                            },
                          )
                        : Text(
                            controller.filePath.value,
                            style: TextStyle(color: Colors.teal),
                          ),
                    MyTextButton(
                      text: "上传",
                      margin: EdgeInsets.only(left: 15),
                      confirm: () {
                        controller.uploadMusic();
                      },
                    ),
                  ],
                ),
              ));
        });
  }
}
